package com.maxuxu.chat.UdpTest;

import java.net.*;

public class Client {
    public static void main(String[] args) throws Exception{
        // 1. 建立一个socket
        DatagramSocket datagramSocket = new DatagramSocket();
        // 2. 建个包
        String msg = "hello，server";
        InetAddress localhost = InetAddress.getByName("localhost");
        int port = 9999;
        // 数据起始,发送目标
        DatagramPacket packet = new DatagramPacket(msg.getBytes(),0,msg.getBytes().length,localhost,port);
        // 3. 发送包
        datagramSocket.send(packet);

        // 4. 关闭流
        datagramSocket.close();
    }
}
